package com.example.minefieldkeepercloud.view;

import android.content.Context;
import android.util.Log;
import android.widget.TextView;

import com.example.minefieldkeepercloud.R;
import com.example.minefieldkeepercloud.bean.ChartFragBean;
import com.github.mikephil.charting.components.MarkerView;
import com.github.mikephil.charting.data.CandleEntry;
import com.github.mikephil.charting.data.Entry;
import com.github.mikephil.charting.highlight.Highlight;
import com.github.mikephil.charting.utils.MPPointF;

import java.util.ArrayList;
import java.util.List;


public class MyMarkerDView extends MarkerView {

    private TextView tv_1,tv_2,tv_3;
    private List<ChartFragBean.DataBean> listt;

    public MyMarkerDView(Context context, int layoutResource) {
        super(context, layoutResource);


        tv_1 = findViewById(R.id.tv_1);
        tv_2 = findViewById(R.id.tv_2);
        tv_3 = findViewById(R.id.tv_3);

    }

    /**
     * 是指横轴日期数据
     */
    public void setTimeList(List<ChartFragBean.DataBean> listtt) {

        listt=listtt;
    }

    @Override
    public void refreshContent(Entry e, Highlight highlight) {

        tv_1.setText("忽略:"+listt.get((int)e.getX()).getHl()+"");
        tv_2.setText("维修:"+listt.get((int)e.getX()).getWx()+"");
        tv_3.setText("维护:"+listt.get((int)e.getX()).getWh()+"");
        super.refreshContent(e, highlight);
    }

    @Override
    public MPPointF getOffset() {
        return new MPPointF(-(getWidth() / 2), -getHeight());
    }
}
